//
//  SVController.m
//  SVProgressHUD
//
//  Created by DYS on 15/12/14.
//  Copyright © 2015年 DYS. All rights reserved.
//

#import "SVController.h"
#import "SVProgressHUD.h"
#import "AFHTTPSessionManager.h"

@interface SVController ()
@property (weak, nonatomic) IBOutlet UITextField *username;
@property (weak, nonatomic) IBOutlet UITextField *password;
@end

@implementation SVController

- (void)viewDidLoad {
    [super viewDidLoad];

}
- (IBAction)btnClick:(id)sender {
    NSString *url = @"http://e.kumi.cn/app/users.php?_s_=17f949bc91ce77d16880a0a4fcb305e5&_t_=1449838936&act=14&channelid=appstore&cityid=1&lat=40.03603559364713&lng=116.3636425291313&password=QzrlVIgGYkhWoF96d74pmg%3D%3D&username=18515838413";
    
    [SVProgressHUD showWithStatus:@"正在登陆..." maskType:SVProgressHUDMaskTypeNone];
     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager GET:url parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSString *err = dict[@"error"];
        if (err) {
            [SVProgressHUD setErrorImage:[UIImage imageNamed:@"tear.PNG"]];
            [SVProgressHUD showErrorWithStatus:@"登陆失败"];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [SVProgressHUD dismiss];
            });
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"%@",error);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
